<?php /* Smarty version 2.6.26, created on 2011-02-16 17:21:34
         compiled from admin/cust-list.html */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('function', 'html_select_date', 'admin/cust-list.html', 265, false),array('function', 'mailto', 'admin/cust-list.html', 351, false),array('function', 'math', 'admin/cust-list.html', 373, false),array('modifier', 'sslash', 'admin/cust-list.html', 340, false),array('modifier', 'default', 'admin/cust-list.html', 340, false),)), $this); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" lang="ru" xml:lang="ru"> 
    <head>
	<title>LocalCRM</title>
	<script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
	<script src="js/jquery-ui-1.8.4.custom.min.js" type="text/javascript"></script>
	<script src="js/jquery.blockUI.js" type="text/javascript"></script>
	<script src="js/jquery.contextMenu.js" type="text/javascript"></script>

	<script src="js/i18n/grid.locale-ru.js" type="text/javascript"></script>
	<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>

	<script src="js/crm/common.js" type="text/javascript"></script>
	<link href="css/redmond/jquery-ui-1.8.4.custom.css" rel="stylesheet" type="text/css"/>
	<link href="css/jquery.contextMenu.css" rel="stylesheet" type="text/css"/>
	<link href="css/ui.jqgrid.css" rel="stylesheet" type="text/css"/>
    </head>
    <body>
	<script type="text/javascript">
	<?php echo '
	<!--
	$(document).ready
	(
	    function()
	    {
		$(\'span#toggle-legend\')
		    .css(\'cursor\',\'pointer\')
		    .toggle
		    (
			function() {$(this).text(\'- Скрыть легенду\').next().slideDown(\'fast\')},
			function() {$(this).text(\'+ Показать легенду\').next().slideUp(\'fast\')}
		    );

		$(\'span#toggle-print-options\')
		    .css(\'cursor\',\'pointer\')
		    .toggle
		    (
			function() {$(this).text(\'- Скрыть\').next().slideDown(\'fast\')},
			function() {$(this).text(\'+ Дополнительно\').next().slideUp(\'fast\')}
		    );

		$(\'input:checkbox#select-all\').click
		(
		    function()
		    {
			if ( $(this).attr(\'checked\') )
			{
			    $(\'input:checkbox.customer-check\').attr(\'checked\',true);
			}
			else
			{
			    $(\'input:checkbox.customer-check\').attr(\'checked\',false);
			}

			if ( checkBoxes()>0 )
			{
			    $(\'center#toolbar\').show();
			}
			else
			{
			    $(\'center#toolbar\').hide();
			}
		    }
		);

		$(\'a.delete-link\').click
		(
		    function()
		    {
			if ( !window.confirm(\'Вы уверены?\') )
			{
			    return false;
			}
		    }
		);

		function checkBoxes()
		{
		    if ( $(\'input.customer-check:checked\').size()==50 )
		    {
			$(\'input:checkbox#select-all\').attr(\'checked\',true);
		    }
		    else
		    {
			$(\'input:checkbox#select-all\').attr(\'checked\',false);
		    }

		    return $(\'input.customer-check:checked\').size();
		}

		if ( checkBoxes()>0 )
		{
		    $(\'center#toolbar\').show();
		}
		else
		{
		    $(\'center#toolbar\').hide();
		}

		$(\'input:checkbox.customer-check\').click
		(
		    function()
		    {
			$.getJSON
			(
			    \'customer.php\',
			    {
				\'do\':		$(this).attr(\'checked\')?\'select\':\'deselect\',
				\'customer\':	$(this).val()
			    }
			);

			if ( checkBoxes()>0 ) { $(\'center#toolbar:hidden\').show(); }
			else { $(\'center#toolbar:visible\').hide(); }
		    }
		);

		$(\'input:checkbox#select-all\').click
		(
		    function()
		    {
			if ( $(this).attr(\'checked\') )
			{
			    if ( window.confirm(\'Нажмите ОК, чтобы отметить все записи в БД, а не только на этой странице\') )
			    {
				$.getJSON
				(
				    \'customer.php\',
				    { \'do\': \'select\' }
				);
			    }
			    else
			    {
				$(\'input:checkbox.customer-check\').each
				(
				    function()
				    {
					$.getJSON
					(
					    \'customer.php\',
					    {
						\'do\':		\'select\',
						\'customer\':	$(this).val()
					    }
					);
				    }
				);
			    }
			}
			else
			{
			    $.getJSON
			    (
				\'customer.php\',
				{ \'do\': \'deselect\' }
			    );
			}
		    }
		);

		$(\'input:button#action-submit\').click
		(
		    function()
		    {
			switch( $(\'select#action\').val() )
			{
			    case	\'print\':
				$(\'#document-period\')
				    .dialog(\'option\',\'title\',\'Печать документов\')
				    .dialog(\'option\',\'resizable\',false)
				    .dialog
				    (
					\'option\',
					\'buttons\',
					{
					    \'Скачать архив\':	function()
								{
								    $(\'input#dateYear\').val($(\'#document-year\').val());
								    $(\'input#dateMonth\').val($(\'#document-month\').val());
								    $(\'form#customer-list\')
									.attr(\'action\',\'/cgi-bin/print.cgi\')
									.submit();
								}
					}
				    )
				    .dialog(\'open\');
				break;

			    case	\'documents-send\':
				$(\'#document-period\')
				    .dialog(\'option\',\'title\',\'Отправка документов\')
				    .dialog(\'option\',\'resizable\',false)
				    .dialog
				    (
					\'option\',
					\'buttons\',
					{
					    \'Отправить документы\':	function()
								{
								    $(\'input#dateYear\').val($(\'#document-year\').val());
								    $(\'input#dateMonth\').val($(\'#document-month\').val());
								    $(\'form#customer-list\')
									.attr(\'action\',\'document-send.php\')
									.submit();
								}
					}
				    )
				    .dialog(\'open\');
				break;
			}
		    }
		);

		$(\'a#fields-tune\').click
		(
		    function()
		    {
			$(\'div#fields\')
			    .dialog(\'option\',\'title\',\'Настройка отображения\')
			    .dialog(\'option\',\'resizable\',false)
			    .dialog
			    (
				\'option\',
				\'buttons\',
				{
				    \'Сохранить\':	function(){$(this).find(\'form\').submit();}
				}
			    )
			    .dialog(\'open\');
		    }
		);

		$(\'a#debug-toggle\').click(function(){$(\'div#debug\').slideToggle();});
	    }
	);
	-->
	'; ?>

	</script>

<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "admin/submodules/_menu.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>

<?php if ($_SESSION['manager']['is_admin'] == 1): ?>
    <?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "admin/submodules/tmanagement.dialog.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
<?php endif; ?>

	<table width="98%" align="center">
	    <tr>
		<td valign="top">
		    		    <?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "admin/submodules/cfilter.module.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
		</td>
		<td valign="top" width="60%">
		    		    <?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "admin/submodules/task.module.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
		</td>
	    </tr>
	</table>

	<hr/>

<!-- Окно выбора периода для работы с документами -->
	<div class="dialog" id="document-period">
		<?php echo smarty_function_html_select_date(array('display_days' => false,'start_year' => 2009,'month_extra' => 'id="document-month"','year_extra' => 'id="document-year"'), $this);?>

	</div>

	<form method="get" id="customer-list">
	<input type="hidden" name="dateYear" id="dateYear"/>
	<input type="hidden" name="dateMonth" id="dateMonth"/>
	</form>

<!-- Меню действий // Появляется только если выделен хотя бы один клиент -->
	<center style="display: none;" id="toolbar">
	    С отмеченными:
	    <select id="action">
		<option value="">&mdash;</option>
		<option value="print">Напечатать</option>
		<option value="documents-send">Отправить документы</option>
	    </select>
	    <input type="button" value="&raquo;" id="action-submit"/>
	</center>

<!-- Окно настриваемых полей -->
    <div class="dialog" id="fields">
	Отображаемые поля:
	<form action="db.php" method="post">
	    <input type="hidden" name="action" value="manager.set_fields.do">
	    <table>
	    <?php $_from = $this->_tpl_vars['defaults']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['field']):
?>
		<tr>
		    <td><?php echo $this->_tpl_vars['field']['title']; ?>
</td>
		    <td align="center"><input type="checkbox" name="<?php echo $this->_tpl_vars['field']['name']; ?>
" value="1" <?php if ($_SESSION['manager']['options']['fields']['customer_list'][$this->_tpl_vars['field']['name']] == true): ?>checked<?php endif; ?>/></td>
		</tr>
	    <?php endforeach; endif; unset($_from); ?>
		<tr><td colspan="2"><hr/></td></tr>
		<?php $_from = $this->_tpl_vars['customs']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['field']):
?>
		<tr>
		    <td><?php echo $this->_tpl_vars['field']['title']; ?>
</td>
		    <td align="center"><input type="checkbox" name="<?php echo $this->_tpl_vars['field']['name']; ?>
" value="1" <?php if ($_SESSION['manager']['options']['fields']['customer_list'][$this->_tpl_vars['field']['name']] == true): ?>checked<?php endif; ?>/></td>
		</tr>
		<?php endforeach; endif; unset($_from); ?>
	    </table>
	</form>
    </div>

<!--
/*
#	ТАБЛИЦА СПИСКА КЛИЕНТОВ
*/
-->
	<table id="customers" class="ui-widget ui-corner-top" width="100%" cellspacing="0" rules="all" style="border: solid 1px #000000;">
	    <thead class="ui-widget-header">
		<tr id="customer-header">
		    <th><a href="?action=customer.new"><img src="images/icons/plus_16.png" title="Добавить клиента" border="0"/></a></th>
		    <th><input type="checkbox" id="select-all" title="Выбрать всех" <?php if ($_SESSION['select']['customer'] == 'all'): ?>checked<?php endif; ?>/></th>
		    <?php $_from = $this->_tpl_vars['defaults']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['field']):
?>
			<?php if ($_SESSION['manager']['options']['fields']['customer_list'][$this->_tpl_vars['field']['name']] == 1): ?>
			    <?php if ($this->_tpl_vars['field']['name'] == 'contact'): ?>
		    <th colspan="2">Контактная информация</th>
			    <?php else: ?>
		    <th><?php echo $this->_tpl_vars['field']['title']; ?>
</th>
			    <?php endif; ?>
			<?php endif; ?>
		    <?php endforeach; endif; unset($_from); ?>
		    <?php $_from = $this->_tpl_vars['customs']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['field']):
?>
			<?php if ($_SESSION['manager']['options']['fields']['customer_list'][$this->_tpl_vars['field']['name']] == 1): ?>
		    <th><?php echo $this->_tpl_vars['field']['title']; ?>
</th>
			<?php endif; ?>
		    <?php endforeach; endif; unset($_from); ?>
		</tr>
	    </thead>
	    <tbody>
	    <?php $_from = $this->_tpl_vars['customers']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }$this->_foreach['customers'] = array('total' => count($_from), 'iteration' => 0);
if ($this->_foreach['customers']['total'] > 0):
    foreach ($_from as $this->_tpl_vars['customer']):
        $this->_foreach['customers']['iteration']++;
?>
		<tr <?php if (!(1 & $this->_foreach['customers']['iteration'])): ?>bgcolor="#f0f0ff"<?php endif; ?> style="word-wrap: break-word;" <?php if ($this->_tpl_vars['customer']['documents_total'] < 4): ?>class="ui-state-error"<?php elseif ($this->_tpl_vars['customer']['documents_total'] >= 4 && $this->_tpl_vars['customer']['documents_total'] > $this->_tpl_vars['customer']['documents_printed']): ?>class="ui-state-higlight"<?php endif; ?>>
		    <td align="center"><a href="customer-delete.php?id=<?php echo $this->_tpl_vars['customer']['id']; ?>
" class="delete-link"><img src="images/icons/delete_16.png" border="0" title="Удалить"/></a></td>
		    <td align="center"><input type="checkbox" class="customer-check" name="account" value="<?php echo $this->_tpl_vars['customer']['account_id']; ?>
" id="customer_<?php echo $this->_tpl_vars['customer']['id']; ?>
" <?php if ($_SESSION['select']['customer'][$this->_tpl_vars['customer']['id']] == 1 || $_SESSION['select']['customer'] == 'all'): ?>checked<?php endif; ?>/></td>
		    <?php $_from = $_SESSION['manager']['options']['fields']['customer_list']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['field_name'] => $this->_tpl_vars['field']):
?>
			<?php if ($this->_tpl_vars['field_name'] == 'customer_name'): ?>
		    <td style="padding-left: 1em;"><a href="customer-view.php?id=<?php echo $this->_tpl_vars['customer']['id']; ?>
"><?php echo ((is_array($_tmp=((is_array($_tmp=$this->_tpl_vars['customer'][$this->_tpl_vars['field_name']])) ? $this->_run_mod_handler('sslash', true, $_tmp) : stripslashes($_tmp)))) ? $this->_run_mod_handler('default', true, $_tmp, '&mdash;') : smarty_modifier_default($_tmp, '&mdash;')); ?>
</a></td>
			<?php elseif ($this->_tpl_vars['field_name'] == 'contact'): ?>
			    <?php if ($this->_tpl_vars['customer']['contact_phone'] != '' || $this->_tpl_vars['customer']['contact_name'] != ''): ?>
				<?php if ($this->_tpl_vars['customer']['contact_phone'] != ''): ?><td <?php if ($this->_tpl_vars['customer']['contact_name'] == ''): ?>colspan="2"<?php endif; ?> align="center"><span class="tel-number"><?php echo $this->_tpl_vars['customer']['contact_phone']; ?>
</span></td><?php endif; ?>
				<?php if ($this->_tpl_vars['customer']['contact_name'] != ''): ?><td <?php if ($this->_tpl_vars['customer']['contact_phone'] == ''): ?>colspan="2"<?php endif; ?> style="padding-left: 1em;"><?php echo $this->_tpl_vars['customer']['contact_name']; ?>
<?php if ($this->_tpl_vars['customer']['contact_post'] != ''): ?>&nbsp;<i>(<?php echo $this->_tpl_vars['customer']['contact_post']; ?>
)</i><?php endif; ?></td><?php endif; ?>
			    <?php else: ?>
		    <td colspan="2" align="center"><i>Контактная информация не указана, <a href="customer-edit.php?id=<?php echo $this->_tpl_vars['customer']['id']; ?>
#contact">указать</a></i></td>
			    <?php endif; ?>
			<?php elseif ($this->_tpl_vars['field_name'] == 'contract_number'): ?>
		    <td align="center"><strong><?php echo ((is_array($_tmp=@$this->_tpl_vars['customer']['contract_number'])) ? $this->_run_mod_handler('default', true, $_tmp, '&mdash;') : smarty_modifier_default($_tmp, '&mdash;')); ?>
</strong><?php if ($this->_tpl_vars['customer']['contracts_total'] > 1): ?>&nbsp;<sup title="Всего объектов данного типа: <?php echo $this->_tpl_vars['customer']['contracts_total']; ?>
"><?php echo $this->_tpl_vars['customer']['contracts_total']; ?>
</sup><?php endif; ?></td>
			<?php elseif ($this->_tpl_vars['field_name'] == 'email'): ?>
		    <td align="center" style="max-width: 150px;"><?php if ($this->_tpl_vars['customer']['email'] != ''): ?><?php echo smarty_function_mailto(array('address' => $this->_tpl_vars['customer']['email']), $this);?>
<?php else: ?>&mdash;<?php endif; ?></td>
			<?php else: ?>
		    <td align="center"><?php echo ((is_array($_tmp=@$this->_tpl_vars['customer'][$this->_tpl_vars['field_name']])) ? $this->_run_mod_handler('default', true, $_tmp, '&mdash;') : smarty_modifier_default($_tmp, '&mdash;')); ?>
</td>
			<?php endif; ?>
		    <?php endforeach; endif; unset($_from); ?>
		</tr>
	    <?php endforeach; else: ?>
		<tr><td align="center" colspan="11">Клиенты не найдены</td></tr>
	    <?php endif; unset($_from); ?>
	    </tbody>
	    <?php if ($this->_tpl_vars['pages'] > 0): ?>
	    <tfoot>
		<tr>
		    <td align="center" colspan="11">
			<?php if ($this->_tpl_vars['page'] == 1): ?>
			<span class="ui-state-disabled">&nbsp;&laquo;&nbsp;</span>
			<?php else: ?>
			<span class="ui-state-default"><a href="?page=1">&nbsp;&laquo;&nbsp;</a></span>
			<?php endif; ?>
			&nbsp;

			<?php if (( $this->_tpl_vars['page'] ) > 0): ?>
			<?php echo smarty_function_math(array('equation' => "x-1",'x' => $this->_tpl_vars['page'],'assign' => 'prev'), $this);?>

			    <?php if ($this->_tpl_vars['prev'] > 0): ?>
			<span class="ui-state-default"><a href="?page=<?php echo $this->_tpl_vars['prev']; ?>
">&nbsp;<?php echo $this->_tpl_vars['prev']; ?>
&nbsp;</a></span>
			    <?php endif; ?>
			<?php endif; ?>
			&nbsp;
			<span class="ui-state-highlight">&nbsp;<?php echo $this->_tpl_vars['page']; ?>
&nbsp;</span>
			&nbsp;
			<?php if (( $this->_tpl_vars['page']+1 ) <= $this->_tpl_vars['pages']): ?>
			<?php echo smarty_function_math(array('equation' => "x+1",'x' => $this->_tpl_vars['page'],'assign' => 'next'), $this);?>

			<span class="ui-state-default"><a href="?page=<?php echo $this->_tpl_vars['next']; ?>
">&nbsp;<?php echo $this->_tpl_vars['next']; ?>
&nbsp;</a></span>
			<?php endif; ?>
			&nbsp;

			<?php if (( $this->_tpl_vars['page']+1 ) > $this->_tpl_vars['pages']): ?>
			<span class="ui-state-disabled">&nbsp;&raquo;&nbsp;</span>
			<?php else: ?>
			<span class="ui-state-default"><a href="?page=<?php echo $this->_tpl_vars['pages']; ?>
">&nbsp;&raquo;&nbsp;</a></span>
			<?php endif; ?>
		    </td>
		</tr>
	    </tfoot>
	    <?php endif; ?>
	</table>

	<br/>
	<div class="ui-widget ui-state-disabled">
	    <center>Найдено <?php echo $this->_tpl_vars['total_rows']; ?>
 записей. Сформировано страниц: <?php echo $this->_tpl_vars['pages']; ?>
, записей на страницу: <?php echo $this->_tpl_vars['limit_rows']; ?>
</center>
	</div>
	<hr/>
	<br/>
	<a href="javascript:void(0)" id="debug-toggle">показать/скрыть</a> отладочную информацию
	<div id="debug" style="display:none" class="ui-state-default">
	    MySQL Query CUSTOMERS:<p class="ui-state-highlight ui-corner-all" style="border: dashed 1px #000000; padding: 1em;"><?php echo $this->_tpl_vars['mysql_query_customers']; ?>
</p>
	    MySQL Query TASKS:<p class="ui-state-highlight ui-corner-all" style="border: dashed 1px #000000; padding: 1em;"><?php echo $this->_tpl_vars['mysql_query_tasks']; ?>
</p>
	    $_SESSION:<pre class="ui-state-highlight ui-corner-all" style="border: dashed 1px #000000; padding: 1em;"><?php print_r($_SESSION) ?></pre>
	</div>
    </body>
</html>